<?php

namespace app\admin\controller;

use think\Db;

class Home extends Base
{

    /**
     * 获取今日统计数据
     */
    public function getHomeData()
    {
        $todayOrder = Db::name('order')
            ->where(['paymentStatus' => 1, 'cancelStatus' => 0])
            ->whereTime('payTime', 'today')
            ->count();

        $vipUser = Db::name('user')
            ->where(['vipEndTime' => ['>', createTime()]])
            ->count();

        $todayUser = Db::name('user')
            ->whereTime('createTime', 'today')
            ->count();

        $data = [
            'todayOrder' => $todayOrder,
            'vipUser' => $vipUser,
            'todayUser' => $todayUser,

        ];

        $data ? $this->suc($data) : $this->err('查询失败');

    }

}
